﻿using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.Serialization;

namespace NWebMock
{
    public interface IHttpClientCertificate : ICollection, ISerializable
    {
        #region Properties

        /// <summary>
        /// Gets all the keys in the NameValueCollection.
        /// </summary>
        string[] AllKeys { get; }

        /// <summary>
        /// Gets the certificate issuer, in binary format.
        /// </summary>
        byte[] BinaryIssuer { get; }

        /// <summary>
        /// Gets the encoding of the certificate.
        /// </summary>
        int CertEncoding { get; }

        /// <summary>
        /// Gets a string containing the binary stream of the entire certificate content, in ASN.1 format.
        /// </summary>
        byte[] Certificate { get; }

        /// <summary>
        /// Gets the unique ID for the client certificate, if provided.
        /// </summary>
        string Cookie { get; }

        /// <summary>
        /// A set of flags that provide additional client certificate information.
        /// </summary>
        int Flags { get; }

        /// <summary>
        /// Gets a value that indicates whether the client certificate is present.
        /// </summary>
        bool IsPresent { get; }

        /// <summary>
        /// A string that contains a list of subfield values containing information about the certificate issuer.
        /// </summary>
        string Issuer { get; }

        /// <summary>
        /// Gets a value that indicates whether the client certificate is valid.
        /// </summary>
        bool IsValid { get; }

        /// <summary>
        /// Gets the entry at the specified index of the NameValueCollection.
        /// </summary>
        /// <param name="index">The zero-based index of the entry to locate in the collection.</param>
        /// <returns>A String that contains the comma-separated list of values at the specified index of the collection.</returns>
        string this[int index] { get; }

        /// <summary>
        /// Gets or sets the entry with the specified key in the NameValueCollection.
        /// </summary>
        /// <param name="name">The String key of the entry to locate. The key can be null.</param>
        /// <returns>A String that contains the comma-separated list of values associated with the specified key, if found; otherwise, null.</returns>
        string this[string name] { get; set; }

        /// <summary>
        /// Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.
        /// </summary>
        ICollection Keys { get; }

        /// <summary>
        /// Gets the number of bits in the digital certificate key size. For example, 128.
        /// </summary>
        int KeySize { get; }

        /// <summary>
        /// Gets the public key binary value from the certificate.
        /// </summary>
        byte[] PublicKey { get; }

        /// <summary>
        /// Gets the number of bits in the server certificate private key. For example, 1024.
        /// </summary>
        int SecretKeySize { get; }

        /// <summary>
        /// Provides the certificate serial number as an ASCII representation of hexadecimal bytes separated by hyphens. For example, 04-67-F3-02.
        /// </summary>
        string SerialNumber { get; }

        /// <summary>
        /// Gets the issuer field of the server certificate.
        /// </summary>
        string ServerIssuer { get; }

        /// <summary>
        /// Gets the subject field of the server certificate.
        /// </summary>
        string ServerSubject { get; }

        /// <summary>
        /// Gets the subject field of the client certificate.
        /// </summary>
        string Subject { get; }

        /// <summary>
        /// Gets the date when the certificate becomes valid. The date varies with international settings.
        /// </summary>
        DateTime ValidFrom { get; }

        /// <summary>
        /// Gets the certificate expiration date.
        /// </summary>
        DateTime ValidUntil { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Copies the entries in the specified NameValueCollection to the current NameValueCollection.
        /// </summary>
        /// <param name="c">The NameValueCollection to copy to the current NameValueCollection.</param>
        void Add(NameValueCollection c);

        /// <summary>
        /// Adds an entry with the specified name and value to the NameValueCollection.
        /// </summary>
        /// <param name="name">The String key of the entry to add. The key can be null.</param>
        /// <param name="value">The String value of the entry to add. The value can be null.</param>
        void Add(string name, string value);

        /// <summary>
        /// Invalidates the cached arrays and removes all entries from the NameValueCollection.
        /// </summary>
        void Clear();

        /// <summary>
        /// Gets the values at the specified index of the NameValueCollection combined into one comma-separated list.
        /// </summary>
        /// <param name="index">The zero-based index of the entry that contains the values to get from the collection.</param>
        /// <returns>A String that contains a comma-separated list of the values at the specified index of the NameValueCollection, if found; otherwise, null.</returns>
        string Get(int index);

        /// <summary>
        /// Returns individual client certificate fields by name.
        /// </summary>
        /// <param name="field">The item in the collection to retrieve. </param>
        /// <returns>The value of the item specified by field.</returns>
        string Get(string field);

        /// <summary>
        /// Gets the key at the specified index of the NameValueCollection.
        /// </summary>
        /// <param name="index">The zero-based index of the key to get from the collection.</param>
        /// <returns>A String that contains the key at the specified index of the NameValueCollection, if found; otherwise, null.</returns>
        string GetKey(int index);

        /// <summary>
        /// Gets the values at the specified index of the NameValueCollection.
        /// </summary>
        /// <param name="index">The zero-based index of the entry that contains the values to get from the collection.</param>
        /// <returns>A String array that contains the values at the specified index of the NameValueCollection, if found; otherwise, null.</returns>
        string[] GetValues(int index);

        /// <summary>
        /// Gets the values associated with the specified key from the NameValueCollection.
        /// </summary>
        /// <param name="name">The String key of the entry that contains the values to get. The key can be null.</param>
        /// <returns>A String array that contains the values associated with the specified key from the NameValueCollection, if found; otherwise, null.</returns>
        string[] GetValues(string name);

        /// <summary>
        /// Gets a value indicating whether the NameValueCollection contains keys that are not null.
        /// </summary>
        /// <returns>true if the NameValueCollection contains keys that are not null; otherwise, false.</returns>
        bool HasKeys();

        /// <summary>
        /// Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.
        /// </summary>
        /// <param name="sender">The source of the deserialization event.</param>
        void OnDeserialization(Object sender);

        /// <summary>
        /// Removes the entries with the specified key from the NameObjectCollectionBase instance.
        /// </summary>
        /// <param name="name">The String key of the entry to remove. The key can be null.</param>
        void Remove(string name);

        /// <summary>
        /// Sets the value of an entry in the NameValueCollection.
        /// </summary>
        /// <param name="name">The String key of the entry to add the new value to. The key can be null.</param>
        /// <param name="value">The Object that represents the new value to add to the specified entry. The value can be null.</param>
        void Set(string name, string value);

        #endregion
    }
}
